// pages/home/home.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    TabCur: 0,
    scrollLeft:0,
    tablist:["推荐","美食","旅行","动漫"],
    allNotelist:[
      {
        coverUrl:"/image/荷丨三部随笔丨TATTOO_1_鑫_来自小红书网页版.jpg",
        title:"荷丨三部随笔丨TATTOO",
        headUrl:"/image/鑫.jpg",
        userName:"鑫",
        likeNum:"1204",
        category:"0"
      },
      {
        coverUrl:"/image/-𝙒𝙚𝘾𝙝𝙖𝙩  _背景图🫧_1_一颗小西柚_来自小红书网页版.jpg",
        title:"-𝙒𝙚𝘾𝙝𝙖𝙩  _背景图🫧",
        headUrl:"/image/一颗小西柚.jpg",
        userName:"一颗小西柚",
        likeNum:"134",
        category:"0"
      },
      {
        coverUrl:"/image/夏天喝的营养汤，清爽滋润不上火！_1_糯米丸子_来自小红书网页版.jpg",
        title:"夏天喝的营养汤，清爽滋润不上火！",
        headUrl:"/image/糯米丸子.jpg",
        userName:"糯米丸子",
        likeNum:"812",
        category:"1"
      },
      {
        coverUrl:"/image/眷思量_小福哥哥又回来啦！_1_看小说家_来自小红书网页版.jpg",
        title:"眷思量_小福哥哥又回来啦！",
        headUrl:"/image/看小说家.jpg",
        userName:"看小说家",
        likeNum:"2454",
        category:"3"
      },
      {
        coverUrl:"/image/_1_吃肉的兔子_来自小红书网页版.jpg",
        title:"仙逆王麻子实在是太好看了！！！",
        headUrl:"/image/吃肉的兔子.jpg",
        userName:"吃肉的兔子",
        likeNum:"25467",
        category:"3"
      },
      {
        coverUrl:"/image/“推荐❾个我认为浪漫又治愈的小众旅行地”_1_是陈同学📸_来自小红书网页版.jpg",
        title:"“推荐❾个我认为浪漫又治愈的小众旅行地”",
        headUrl:"/image/是陈同学📸.jpg",
        userName:"是陈同学📸",
        likeNum:"999",
        category:"2"
      },
      {
        coverUrl:"/image/武汉你已经进化到这种程度了吗？？_1_Lolipp_来自小红书网页版.jpg",
        title:"武汉你已经进化到这种程度了吗？？",
        headUrl:"/image/Lolipp.jpg",
        userName:"Lolipp",
        likeNum:"652",
        category:"1"
      },
      {
        coverUrl:"/image/推荐8⃣个不冷门但充满惊喜的城市，暑假冲_1_小慧姐假日带娃旅行_来自小红书网页版.jpg",
        title:"推荐8个不冷门但充满惊喜的城市，暑假冲",
        headUrl:"/image/小慧姐假日带娃旅行.jpg",
        userName:"小慧姐假日带娃旅行",
        likeNum:"4399",
        category:"2"
      },
      {
        coverUrl:"/image/跟着国家地理打卡中国，去过的9个最美旅行地_1_卡布奇诺Bo_来自小红书网页版.jpg",
        title:"跟着国家地理打卡中国，去过的9个最美旅行地",
        headUrl:"/image/卡布奇诺Bo.jpg",
        userName:"卡布奇诺Bo",
        likeNum:"542",
        category:"2"
      },
      {
        coverUrl:"/image/这个设定好牛“现代打工人穿越古代当妖妃”❗️_1_华瓜追剧_来自小红书网页版.jpg",
        title:"这个设定好牛“现代打工人穿越古代当妖妃”❗️",
        headUrl:"/image/华瓜追剧.jpg",
        userName:"华瓜追剧",
        likeNum:"8524",
        category:"3"
      },
      {
        coverUrl:"/image/婉儿大婚妆造好漂亮～_1_初见_来自小红书网页版.jpg",
        title:"婉儿大婚妆造好漂亮～",
        headUrl:"/image/初见.jpg",
        userName:"初见",
        likeNum:"999",
        category:"3"
      },
      {
        coverUrl:"/image/景德镇快乐行动行动_1_太有实力了哥们_来自小红书网页版.jpg",
        title:"景德镇快乐行动行动",
        headUrl:"/image/太有实力了哥们.jpg",
        userName:"太有实力了哥们",
        likeNum:"346",
        category:"2"
      },
      {
        coverUrl:"/image/中国地质博物馆_1_香蕉_来自小红书网页版.jpg",
        title:"中国地质博物馆",
        headUrl:"/image/香蕉.jpg",
        userName:"香蕉",
        likeNum:"54",
        category:"0"
      },
      {
        coverUrl:"/image/盛夏抵，始青天，百福至 ‖蓝色系列壁纸_1_福知一_来自小红书网页版.jpg",
        title:"盛夏抵，始青天，百福至 ‖蓝色系列壁纸",
        headUrl:"/image/福知一.jpg",
        userName:"福知一",
        likeNum:"2454",
        category:"0"
      },
      {
        coverUrl:"/image/我出息了，做了超好吃葱花肉饼_1_豆芽的辅食日记_来自小红书网页版.jpg",
        title:"我出息了，做了超好吃葱花肉饼",
        headUrl:"/image/豆芽的辅食日记.jpg",
        userName:"豆芽的辅食日记",
        likeNum:"344",
        category:"1"
      },
      {
        coverUrl:"/image/树莓里面竟然长这样😲😲😲_1_Heejin_来自小红书网页版.jpg",
        title:"树莓里面竟然长这样😲😲😲",
        headUrl:"/image/Heejin.jpg",
        userName:"Heejin",
        likeNum:"4556",
        category:"1"
      }
    ]
  },
  tabSelect(e) {

    let categoryId = e.currentTarget.dataset.id;
    let notelist = this.data.allNotelist;
    let newNoteList = [];
    for (let index = 0;index < notelist.length;index++) {
      if(notelist[index].category == categoryId){
        newNoteList.push(notelist[index])
      }
    }
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id-1)*60,
      notelist:newNoteList
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let categoryId = 0;
    let notelist = this.data.allNotelist;
    let newNoteList = [];
    for (let index = 0;index < notelist.length;index++) {
      if(notelist[index].category == categoryId){
        newNoteList.push(notelist[index])
      }
    }
    this.setData({
      notelist:newNoteList
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})